package webreg.model;

import javax.xml.bind.annotation.*;

/** Enumeration class that encapsulates the sex of an athlet
 * 
 * @author STKNOLL
 */
@XmlAccessorType(XmlAccessType.NONE)
@XmlEnum(String.class)
public enum Sex {
	@XmlEnumValue("m")
	MALE ('M'),			// the value for male athlets
	@XmlEnumValue("w")
	FEMALE ('W');		// for female athlets

	private final char mValue;		// holds the sign
	
	/** Constructor to create a new sex
	 * 
	 * @param sign The character sign for the sex
	 */
	private Sex(char sign) {
		this.mValue = sign; 
	}

	/** Returns the internal value of the enum
	 */
	public char getValue() {
		return mValue;
	} 
	
	/** Compares a given sex with this one
	 * 
	 * @param toCompare The value to compare
	 * @return True if equal, else false
	 */
	public boolean equals(Sex toCompare) {
		if (toCompare.mValue != this.mValue) return false;
		return true;
	}
	
	/** Returns the spring representation of the enum
	 * 
	 * @see java.lang.Enum#toString()
	 */
	@Override
	public String toString() {
		return String.valueOf(mValue);
	}	
	
	
}
